package com.cc.pojo;

import com.cc.pojo.dto.ParametersDto;
import com.cc.pojo.enums.JudgeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @User c.c
 * @Since 2023/4/12
 * @Time 15:39
 * @Description
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class WhereParams {
  private String propertyName;
  private String condition;

  private String judgmentParameters;


  public static WhereParams convertWhereParamsByParametersDto(ParametersDto parametersDto) {
    WhereParams whereParams = new WhereParams();
    whereParams.setPropertyName(parametersDto.getDataBaseParam());
    whereParams.setCondition(JudgeEnum.from(parametersDto.getCompareType()).getValue());
    whereParams.setJudgmentParameters(parametersDto.getParameter());
    return whereParams;
  }
}
